package com.cjj.service.impl;

import com.cjj.service.TBodyTypeService;
import com.cjj.vo.TBodyTypeVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.mapper.TBodyTypeMapper;
import com.guigu.mapper.TMemberMapper;
import com.guigu.pojo.TBodyType;
import com.guigu.pojo.TMember;
import com.guigu.viwe.PageVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service
public class TBodyTypeServiceImpl implements TBodyTypeService {
    @Resource
    private TBodyTypeMapper tBodyTypeMapper;

    @Resource
    private TMemberMapper tMemberMapper;

    //    分页查询
    @Override
    public PageInfo<TBodyTypeVo> queryType(PageVo<TBodyTypeVo> pageVo) {
        PageHelper.startPage(pageVo.getCurrentPage(), pageVo.getPageSize());
        PageInfo<TBodyTypeVo> tBodyTypeVoPageInfo = new PageInfo<>(this.tBodyTypeMapper.queryType(pageVo.getCondition()));
        return tBodyTypeVoPageInfo;
    }

    //  查询是否有体检过
    @Override
    public TBodyType queryTypeIsNull(String fileName) {
        return this.tBodyTypeMapper.queryTypeIsNull(fileName);
    }

//    添加体检
    @Override
    public int addBodyType(TBodyType tBodyType) {
         this.tBodyTypeMapper.insertSelective(tBodyType);
        TMember tMember= this.tMemberMapper.queryTMember(tBodyType.gettMemberId());
        return  this.tBodyTypeMapper.updateOrder(tMember.getId());
    }
}
